﻿using System;
using System.Collections.Generic;
using System.Linq;

using System.Web;
using System.Web.Mvc;
using SimpleApp.Models;


namespace SimpleApp.Controllers
{
    public class MilestoneController : Controller
    {
        private SelfInfoEntities SelfInfo = new SelfInfoEntities();
        public ActionResult Index()
        {
            List<MILESTONE> inslist = SelfInfo.MILESTONE.ToList<MILESTONE>();
            return View(inslist);
        }

        public ActionResult Add()
        {
            var query = SelfInfo.RECODE.Where(c => c.TYPE == "MILESTONE_OWNER");
            ViewData["MILESTONE_OWNER"] = new SelectList(query.AsEnumerable(), "ID", "RECODEVALUE");
            return View();
        }

        [HttpPost]
        public ActionResult Add(MILESTONE item)
        {

            if (ModelState.IsValid)
            {
                SelfInfo.MILESTONE.Add(item);
                SelfInfo.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(item);

        }
    }
}
